var logistRecordAddCtrl  = new XFApp.client();
$.views.converters({
	
});

XFApp.client.prototype.logistRecordAdd = {
		successCode : 10000,	
		urlItems : {			
			saveURL: basePath+"/userCenter/logisticsRecord/save",
		},
		
		formValidate : function(){
			$("#addForm").validate({
		        rules: {
		        	customerCode: "required",
		        	customerName: "required",
		        	logisticsCode: "required",
		        	logisticsName: "required",
		        	appUId: "required",
		        	appUName: "required"
		        	
				  },
				 messages: {
					 customerCode: "请填写客户代码",
			         customerName: "请填写企业名称",
			         logisticsCode: "请填写物流企业代码",
			         logisticsName: "请填写物流企业名称",
			         appUId: "请填写持卡人编号",
			         appUName: "请填写持卡人姓名"
			         }
		    });
			$("#addForm").validate();
		},
		
		event : function (){			
			_this = this;
			
			$("#submitBtn").on("click",function(){				
				if($("#addForm").validate().form()){
					logistRecordAddCtrl.logistRecordAdd.submit();
				}				
			});
			//表单验证
			_this.formValidate();	
		},		
		
		
		submit : function (){
			
			var entity = {
					logisticsCode : $("#logisticsCode").val(),
					logisticsName : $("#logisticsName").val(),
					customerCode : $("#customerCode").val(),
					customerName : $("#customerName").val(),
					appUName : $("#appUName").val(),
					appUId :$("#appUId").val(),
					auditState:"0"
			}
			
			$.ajax({
	    		url :_this.urlItems.saveURL,
	    		data : entity ,
	    		dataType : "json",
	    		type : 'post',
	    		success : function(data) {				
	    			if(data.code==_this.successCode){ 
	    				window.webDialogUtil.alert("提示",data.msg);	
	    				$('#addForm')[0].reset(); 
	    				//window.location.href= basePath+"/userCenter/logisticsRecord/index" ;
	    			}else{
	    				window.webDialogUtil.alert("提示",data.msg);
	    			}
	    		}
	    	});
		},
	
		
},

$(function(){	
	logistRecordAddCtrl.logistRecordAdd.event();
	
});